home *** CD-ROM | disk | FTP | other *** search
/ Language/OS - Multiplatform Resource Library / LANGUAGE OS.iso / cocktail / cg.lha / cg / src / mod1.puma < prev    next >
Text File  |  1992-11-24  |  31KB  |  1,093 lines

  1. /* Ich, Doktor Josef Grosch, Informatiker, 22.3.1989 */
  2.  
  3. TRAFO TreeMod1
  4. TREE Tree
  5. PUBLIC TreeDefMod TreeImplMod ImportList
  6.  
  7. EXPORT {
  8. CONST BSS    = 32;    (* BITSET size *)
  9. }
  10.  
  11. GLOBAL {
  12.  
  13. FROM General    IMPORT Max;
  14. FROM IO        IMPORT WriteS, WriteNl;
  15. FROM Idents    IMPORT tIdent;
  16. FROM Texts    IMPORT WriteText;
  17. FROM Sets    IMPORT IsElement, Include;
  18. FROM TreeMod2    IMPORT TreeIO, GetIterator, Iterator, WriteLine;
  19.  
  20. FROM Tree    IMPORT
  21.    NoTree    , tTree        , Input        , Reverse    ,
  22.    Class    , Child        , Attribute    , Abstract    ,
  23.    HasChildren    , HasAttributes    , NoCodeAttr    , NoCodeClass    ,
  24.    Options    , TreeRoot    , ClassCount    , iNoTree    ,
  25.    itTree    , iMain        , iModule    , f        ,
  26.    WI    , WN    , ForallClasses    , ForallAttributes, Ignore    ,
  27.    Test        , Dummy        ;
  28.  
  29. IMPORT Strings;
  30.  
  31. VAR
  32.    ConstCount    ,
  33.    ListCount    : INTEGER;
  34.    iRange    ,
  35.    iClassName    : tIdent;
  36.    Node        : tTree;
  37.    gBitCount    : SHORTCARD;
  38.    i, MaxBit    : SHORTCARD;
  39. }
  40.  
  41. BEGIN { ConstCount := 0; }
  42.  
  43. PROCEDURE TreeDefMod (t: Tree)
  44.  
  45. Ag (..) :- {
  46.     !DEFINITION MODULE ! WI (iModule); !;!
  47.     !!
  48.       IF IsElement (ORD ('<'), Options) THEN
  49.     !FROM ! WI (iMain); ! IMPORT ! WI (itTree); !, tProcTree;!
  50.       END;
  51.     !IMPORT SYSTEM, IO;!
  52.     WriteLine (TreeCodes^.Codes.ImportLine);
  53.     WriteText (f, TreeCodes^.Codes.Import);
  54.     Node := Modules;
  55.     WHILE Node^.Kind = Tree.Module DO
  56.        WriteLine (Node^.Module.TreeCodes^.Codes.ImportLine);
  57.        WriteText (f, Node^.Module.TreeCodes^.Codes.Import);
  58.        Node := Node^.Module.Next;
  59.     END;
  60.     !!
  61.       IF NOT IsElement (ORD ('<'), Options) THEN
  62.     !CONST!
  63.     WI (iNoTree); ! = NIL;!
  64.     !!
  65.     ForallClasses (Classes, ConstDecls);
  66.     !!
  67.     !TYPE ! WI (itTree); ! = POINTER TO yyNode;!
  68.     !tProcTree = PROCEDURE (! WI (itTree); !);!
  69.       END;
  70.     WriteLine (TreeCodes^.Codes.ExportLine);
  71.     WriteText (f, TreeCodes^.Codes.Export);
  72.     Node := Modules;
  73.     WHILE Node^.Kind = Tree.Module DO
  74.        WriteLine (Node^.Module.TreeCodes^.Codes.ExportLine);
  75.        WriteText (f, Node^.Module.TreeCodes^.Codes.Export);
  76.        Node := Node^.Module.Next;
  77.     END;
  78.     !!
  79.       IF NOT IsElement (ORD ('<'), Options) THEN
  80.     !# ifndef yyNodeHead!
  81.     !# define yyNodeHead!
  82.     !# endif!
  83.     !TYPE!
  84.       IF IsElement (ORD ('L'), Options) THEN
  85.     MaxBit := 0;
  86.     ForallClasses (Classes, CompMaxBit);
  87.     !yytNodeHead = RECORD yyKind, yyMark, yyOffset: SHORTCARD; yyParent: ! WI (itTree); !; yyIsComp0! 
  88.       IF IsElement (ORD ('5'), Options) THEN
  89.     !, yyIsDone0! 
  90.       END;
  91.     FOR i := 1 TO (MaxBit - 1) DIV BSS DO
  92.        !, yyIsComp! WN (i);
  93.       IF IsElement (ORD ('5'), Options) THEN
  94.        !, yyIsDone! WN (i);
  95.       END;
  96.     END;
  97.     !: BITSET; yyNodeHead END;!
  98.       ELSE
  99.     !yytNodeHead = RECORD yyKind, yyMark: SHORTCARD; yyNodeHead END;!
  100.       END;
  101.     ForallClasses (Classes, TypeDeclNode);
  102.     !!
  103.     !yyNode = RECORD!
  104.     !CASE : SHORTCARD OF!
  105.     !| 0: Kind: SHORTCARD;!
  106.     !| ! WN (ClassCount + 1); !: yyHead: yytNodeHead;!
  107.     ForallClasses (Classes, TypeDeclRecord);
  108.     !END;!
  109.     !END;!
  110.     !!
  111.     !VAR ! WI (iMain); !Root    : ! WI (itTree); !;!
  112.     !VAR HeapUsed    : LONGCARD;!
  113.     !VAR yyPoolFreePtr, yyPoolMaxPtr    : SYSTEM.ADDRESS;!
  114.     !VAR yyNodeSize    : ARRAY [0..! WN (ClassCount); !] OF SHORTCARD;!
  115.     !VAR yyExit    : PROC;!
  116.     !!
  117.     !PROCEDURE yyAlloc    (): ! WI (itTree); !;!
  118.     !PROCEDURE Make! WI (iMain); !    (Kind: SHORTCARD): ! WI (itTree); !;!
  119.     !PROCEDURE IsType    (Tree: ! WI (itTree); !; Kind: SHORTCARD): BOOLEAN;!
  120.     !!
  121.       END;
  122.       IF IsElement (ORD ('n'), Options) THEN
  123.     ForallClasses (Classes, ProcedureDeclsn);
  124.     !!
  125.       END;
  126.       IF IsElement (ORD ('m'), Options) THEN
  127.     ForallClasses (Classes, ProcedureHeadingm);
  128.     !!
  129.       END;
  130.       IF IsElement (ORD ('f'), Options) THEN
  131.     !PROCEDURE Release! WI (iModule); !    (Tree: ! WI (itTree); !);!
  132.       END;
  133.       IF IsElement (ORD ('F'), Options) AND NOT IsElement (ORD ('<'), Options) THEN
  134.     !PROCEDURE Release! WI (iModule); !Module;!
  135.       END;
  136.       IF IsElement (ORD ('o'), Options) THEN
  137.     !PROCEDURE Write! WI (iModule); !Node    (f: IO.tFile; Tree: ! WI (itTree); !);!
  138.       END;
  139.       IF IsElement (ORD ('w'), Options) THEN
  140.     !PROCEDURE Write! WI (iModule); !    (f: IO.tFile; Tree: ! WI (itTree); !);!
  141.       END;
  142.       IF IsElement (ORD ('r'), Options) THEN
  143.     !PROCEDURE Read! WI (iModule); !    (f: IO.tFile): ! WI (itTree); !;!
  144.       END;
  145.       IF IsElement (ORD ('p'), Options) THEN
  146.     !PROCEDURE Put! WI (iModule); !    (f: IO.tFile; Tree: ! WI (itTree); !);!
  147.       END;
  148.       IF IsElement (ORD ('g'), Options) THEN
  149.     !PROCEDURE Get! WI (iModule); !    (f: IO.tFile): ! WI (itTree); !;!
  150.       END;
  151.       IF IsElement (ORD ('t'), Options) THEN
  152.     !PROCEDURE Traverse! WI (iModule); !TD    (Tree: ! WI (itTree); !; Proc: tProcTree);!
  153.       END;
  154.       IF IsElement (ORD ('b'), Options) THEN
  155.     !PROCEDURE Traverse! WI (iModule); !BU    (Tree: ! WI (itTree); !; Proc: tProcTree);!
  156.       END;
  157.       IF IsElement (ORD ('R'), Options) THEN
  158.     !PROCEDURE Reverse! WI (iModule); !    (Tree: ! WI (itTree); !): ! WI (itTree); !;!
  159.       END;
  160.       IF IsElement (ORD ('y'), Options) THEN
  161.     !PROCEDURE Copy! WI (iModule); !    (Tree: ! WI (itTree); !): ! WI (itTree); !;!
  162.       END;
  163.       IF IsElement (ORD ('k'), Options) THEN
  164.     !PROCEDURE Check! WI (iModule); !    (Tree: ! WI (itTree); !): BOOLEAN;!
  165.       END;
  166.       IF IsElement (ORD ('q'), Options) THEN
  167.     !PROCEDURE Query! WI (iModule); !    (Tree: ! WI (itTree); !);!
  168.       END;
  169.       IF IsElement (ORD ('='), Options) THEN
  170.     !PROCEDURE IsEqual! WI (iModule); !    (Tree1, Tree2: ! WI (itTree); !): BOOLEAN;!
  171.       END;
  172.       IF IsElement (ORD ('L'), Options) THEN
  173.     !PROCEDURE Init! WI (iModule); !    (Tree: ! WI (itTree); !);!
  174.       END;
  175.     !PROCEDURE Begin! WI (iModule); !;!
  176.     !PROCEDURE Close! WI (iModule); !;!
  177.     !!
  178.     !END ! WI (iModule); !.!
  179. }; .
  180.  
  181.  
  182. PROCEDURE ConstDecls (t: Tree)
  183.  
  184. Class (..) :- {
  185.     IF NOT (Abstract IN Properties) THEN
  186.        INC (ConstCount);
  187.        IF NOT (Ignore IN Properties) THEN
  188.           WI (Name); ! = ! WN (ConstCount); !;!
  189.        END;
  190.     END;
  191. }; .
  192.  
  193.  
  194. PROCEDURE TypeDeclNode (t: Tree)
  195.  
  196. Class (..) :- {
  197.     IF (NoCodeClass * Properties) = {} THEN
  198.        !y! WI (Name); ! = RECORD yyHead: yytNodeHead; ! 
  199.        ForallAttributes (t, TypeDeclNode); !END;!
  200.     END;
  201. }; .
  202. Child (..) :- {
  203.     WI (Name); !: ! WI (itTree); !; ! 
  204. }; .
  205. Attribute (..) :- {
  206.     IF (NoCodeAttr * Properties) = {} THEN 
  207.        WI (Name); !: ! WI (Type); !; ! 
  208.     END;
  209. }; .
  210.  
  211.  
  212. PROCEDURE TypeDeclRecord (t: Tree)
  213.  
  214. Class (..) :- {
  215.     IF (NoCodeClass * Properties) = {} THEN
  216.        !| ! WI (Name); !: ! WI (Name); !: y! WI (Name); !;!
  217.     END;
  218. }; .
  219.  
  220.  
  221. PROCEDURE ProcedureDeclsn (t: Tree)
  222.  
  223. Class (..) :- {
  224.     IF (NoCodeClass * Properties) = {} THEN
  225.        !PROCEDURE n! WI (Name); ! (): ! WI (itTree); !;!
  226.     END;
  227. }; .
  228.  
  229.  
  230. PROCEDURE ProcedureHeadingm (t: Tree)
  231.  
  232. Class (..) :- {
  233.     IF (NoCodeClass * Properties) = {} THEN
  234.        ListCount := 0;
  235.        !PROCEDURE m! WI (Name); ! (! 
  236.        ForallAttributes (t, ProcedureHeadingm); !): ! WI (itTree); !;!
  237.     END;
  238. }; .
  239. Child (..) :- {
  240.     IF Input IN Properties THEN
  241.        IF ListCount > 0 THEN !; ! END;
  242.        !p! WI (Name); !: ! WI (itTree);
  243.        INC (ListCount);
  244.     END;
  245. }; .
  246. Attribute (..) :- {
  247.     IF Input IN Properties THEN
  248.        IF ListCount > 0 THEN !; ! END;
  249.        !p! WI (Name); !: ! WI (Type);
  250.        INC (ListCount);
  251.     END;
  252. }; .
  253.  
  254.  
  255. PROCEDURE TreeImplMod (t: Tree)
  256.  
  257. Ag (..) :- {
  258.     !IMPLEMENTATION MODULE ! WI (iModule); !;!
  259.     !# define yyALLOC(ptr, size)    ptr := yyPoolFreePtr; \!
  260.     !  IF SYSTEM.ADDRESS (ptr) >= yyPoolMaxPtr THEN ptr := yyAlloc (); END; \!
  261.     !  INC (yyPoolFreePtr, size);!
  262.     !# define yyFREE(ptr, size)    !
  263.     !!
  264.     !IMPORT SYSTEM, System, General, Memory, DynArray, IO, Layout, StringMem, Strings, Idents, Texts, Sets, Positions;!
  265.       IF IsElement (ORD ('<'), Options) THEN
  266.     !FROM ! WI (iMain); ! IMPORT ! WI (itTree); !, ! WI (iNoTree); !, tProcTree, Make! WI (iMain); !, IsType, yyExit,!
  267.     ForallClasses (Classes, ImportConst);
  268.     !yyAlloc, yyPoolFreePtr, yyPoolMaxPtr, yyNodeSize;!
  269.     !!
  270.       END;
  271.     WriteLine (TreeCodes^.Codes.GlobalLine);
  272.     WriteText (f, TreeCodes^.Codes.Global);
  273.     Node := Modules;
  274.     WHILE Node^.Kind = Tree.Module DO
  275.        WriteLine (Node^.Module.TreeCodes^.Codes.GlobalLine);
  276.        WriteText (f, Node^.Module.TreeCodes^.Codes.Global);
  277.        Node := Node^.Module.Next;
  278.     END;
  279.     WriteLine (TreeCodes^.Codes.LocalLine);
  280.     WriteText (f, TreeCodes^.Codes.Local);
  281.     Node := Modules;
  282.     WHILE Node^.Kind = Tree.Module DO
  283.        WriteLine (Node^.Module.TreeCodes^.Codes.LocalLine);
  284.        WriteText (f, Node^.Module.TreeCodes^.Codes.Local);
  285.        Node := Node^.Module.Next;
  286.     END;
  287.     @# include "yy@ WI (iModule); @.w"@
  288.     !!
  289.       IF NOT IsElement (ORD ('<'), Options) THEN
  290.     !CONST yyBlockSize = 20480;!
  291.     !!
  292.     !TYPE!
  293.     ! yytBlockPtr    = POINTER TO yytBlock;!
  294.     ! yytBlock    = RECORD!
  295.     !             yyBlock    : ARRAY [1..yyBlockSize] OF CHAR;!
  296.     !             yySuccessor: yytBlockPtr;!
  297.     !          END;!
  298.     !!
  299.     !VAR yyBlockList    : yytBlockPtr;!
  300.     !VAR yyMaxSize, yyi    : SHORTCARD;!
  301.     !VAR yyTypeRange    : ARRAY [0..! WN (ClassCount); !] OF SHORTCARD;!
  302.     !!
  303.     !PROCEDURE yyAlloc (): ! WI (itTree); !;!
  304.     ! VAR yyBlockPtr    : yytBlockPtr;!
  305.     ! BEGIN!
  306.     !  yyBlockPtr    := yyBlockList;!
  307.     !  yyBlockList    := Memory.Alloc (SYSTEM.TSIZE (yytBlock));!
  308.     !  yyBlockList^.yySuccessor := yyBlockPtr;!
  309.     !  yyPoolFreePtr    := SYSTEM.ADR (yyBlockList^.yyBlock);!
  310.     !  yyPoolMaxPtr    := yyPoolFreePtr + yyBlockSize - yyMaxSize + 1;!
  311.     !  INC (HeapUsed, yyBlockSize);!
  312.     !  RETURN yyPoolFreePtr;!
  313.     ! END yyAlloc;!
  314.     !!
  315.     !PROCEDURE Make! WI (iMain); ! (yyKind: SHORTCARD): ! WI (itTree); !;!
  316.     ! VAR yyByteCount    : LONGINT;!
  317.     ! VAR yyt    : ! WI (itTree); !;!
  318.     ! BEGIN!
  319.     !  yyALLOC (yyt, yyNodeSize [yyKind])!
  320.     !  yyt^.yyHead.yyMark := 0;!
  321.     !  yyt^.Kind := yyKind;!
  322.     !  RETURN yyt;!
  323.     ! END Make! WI (iMain); !;!
  324.     !!
  325.     !PROCEDURE IsType (yyTree: ! WI (itTree); !; yyKind: SHORTCARD): BOOLEAN;!
  326.     ! BEGIN!
  327.     !  RETURN (yyTree # ! WI (iNoTree); !) AND (yyKind <= yyTree^.Kind) AND (yyTree^.Kind <= yyTypeRange [yyKind]);!
  328.     ! END IsType;!
  329.     !!
  330.       END;
  331.       IF IsElement (ORD ('n'), Options) THEN
  332.     ForallClasses (Classes, ProcedureBodyn);
  333.       END;
  334.     !!
  335.       IF IsElement (ORD ('m'), Options) THEN
  336.     ForallClasses (Classes, ProcedureBodym);
  337.       END;
  338.     TreeIO (t);
  339.       IF IsElement (ORD ('f'), Options) THEN
  340.     !PROCEDURE Release! WI (iModule); ! (yyt: ! WI (itTree); !);!
  341.     ! BEGIN!
  342.     !  yyMark (yyt);!
  343.     !  yyRelease! WI (iModule); ! (yyt);!
  344.     ! END Release! WI (iModule); !;!
  345.     !!
  346.     !VAR yyChild    : ! WI (itTree); !;!
  347.     !!
  348.     !PROCEDURE yyRelease! WI (iModule); ! (yyt: ! WI (itTree); !);!
  349.     ! BEGIN!
  350.     !  IF yyt = ! WI (iNoTree); ! THEN RETURN; END;!
  351.     !  CASE yyt^.Kind OF!
  352.     ForallClasses (Classes, ReleaseAttributes1);
  353.     !  ELSE!
  354.     !  END;!
  355.     !!
  356.     !  DEC (yyt^.yyHead.yyMark);!
  357.     !  IF yyt^.yyHead.yyMark = 0 THEN!
  358.     !   CASE yyt^.Kind OF!
  359.     ForallClasses (Classes, ReleaseAttributes2);
  360.     !   ELSE!
  361.     !   END;!
  362.     !   yyFREE (yyt, yyNodeSize [yyt^.Kind])!
  363.     !  END;!
  364.     ! END yyRelease! WI (iModule); !;!
  365.     !!
  366.       END;
  367.       IF IsElement (ORD ('F'), Options) AND NOT IsElement (ORD ('<'), Options) THEN
  368.     !PROCEDURE Release! WI (iModule); !Module;!
  369.     ! VAR yyBlockPtr    : yytBlockPtr;!
  370.     ! BEGIN!
  371.     !  WHILE yyBlockList # NIL DO!
  372.     !   yyBlockPtr    := yyBlockList;!
  373.     !   yyBlockList    := yyBlockList^.yySuccessor;!
  374.     !   Memory.Free (SYSTEM.TSIZE (yytBlock), yyBlockPtr);!
  375.     !  END;!
  376.     !  yyPoolFreePtr    := NIL;!
  377.     !  yyPoolMaxPtr    := NIL;!
  378.     !  HeapUsed    := 0;!
  379.     ! END Release! WI (iModule); !Module;!
  380.     !!
  381.       END;
  382.       IF IsElement (ORD ('t'), Options) OR
  383.          IsElement (ORD ('b'), Options) THEN
  384.     !VAR yyProc    : tProcTree;!
  385.     !!
  386.       END;
  387.       IF IsElement (ORD ('t'), Options) THEN
  388.     !PROCEDURE Traverse! WI (iModule); !TD (yyt: ! WI (itTree); !; yyyProc: tProcTree);!
  389.     ! BEGIN!
  390.     !  yyMark (yyt);!
  391.     !  yyProc := yyyProc;!
  392.     !  yyTraverse! WI (iModule); !TD (yyt);!
  393.     ! END Traverse! WI (iModule); !TD;!
  394.     !!
  395.     !PROCEDURE yyTraverse! WI (iModule); !TD (yyt: ! WI (itTree); !);!
  396.     ! BEGIN!
  397.     !  LOOP!
  398.     !   IF (yyt = ! WI (iNoTree); !) OR (yyt^.yyHead.yyMark = 0) THEN RETURN; END;!
  399.     !   yyt^.yyHead.yyMark := 0;!
  400.     !   yyProc (yyt);!
  401.     !!
  402.     !   CASE yyt^.Kind OF!
  403.     ForallClasses (Classes, TraverseTD);
  404.     !   ELSE RETURN;!
  405.     !   END;!
  406.     !  END;!
  407.     ! END yyTraverse! WI (iModule); !TD;!
  408.     !!
  409.       END;
  410.       IF IsElement (ORD ('b'), Options) THEN
  411.     !PROCEDURE Traverse! WI (iModule); !BU (yyt: ! WI (itTree); !; yyyProc: tProcTree);!
  412.     ! BEGIN!
  413.     !  yyMark (yyt);!
  414.     !  yyProc := yyyProc;!
  415.     !  yyTraverse! WI (iModule); !BU (yyt);!
  416.     ! END Traverse! WI (iModule); !BU;!
  417.     !!
  418.     !PROCEDURE yyTraverse! WI (iModule); !BU (yyt: ! WI (itTree); !);!
  419.     ! BEGIN!
  420.     !  IF (yyt = ! WI (iNoTree); !) OR (yyt^.yyHead.yyMark = 0) THEN RETURN; END;!
  421.     !  yyt^.yyHead.yyMark := 0;!
  422.     !!
  423.     !  CASE yyt^.Kind OF!
  424.     ForallClasses (Classes, TraverseBU);
  425.     !  ELSE!
  426.     !  END;!
  427.     !  yyProc (yyt);!
  428.     ! END yyTraverse! WI (iModule); !BU;!
  429.     !!
  430.       END;
  431.       IF IsElement (ORD ('R'), Options) THEN
  432.     !PROCEDURE Reverse! WI (iModule); ! (yyOld: ! WI (itTree); !): ! WI (itTree); !;!
  433.     ! VAR yyNew, yyNext, yyTail    : ! WI (itTree); !;!
  434.     ! BEGIN!
  435.     !  yyNew    := yyOld;!
  436.     !  yyTail    := yyOld;!
  437.     !  LOOP!
  438.     !   CASE yyOld^.Kind OF!
  439.     ForallClasses (Classes, Reverse1);
  440.     !   ELSE EXIT;!
  441.     !   END;!
  442.     !   yyNew    := yyOld;!
  443.     !   yyOld    := yyNext;!
  444.     !  END;!
  445.     !  CASE yyTail^.Kind OF!
  446.     ForallClasses (Classes, Reverse2);
  447.     !  ELSE!
  448.     !  END;!
  449.     !  RETURN yyNew;!
  450.     ! END Reverse! WI (iModule); !;!
  451.     !!
  452.       END;
  453.       IF IsElement (ORD ('y'), Options) THEN
  454.         !CONST yyInitOldToNewStoreSize    = 32;!
  455.     !!
  456.     !TYPE yytOldToNew = RECORD yyOld, yyNew: ! WI (itTree); !; END;!
  457.     !!
  458.         !VAR yyOldToNewStoreSize    : LONGINT;!
  459.     !VAR yyOldToNewStorePtr    : POINTER TO ARRAY [0..50000] OF yytOldToNew;!
  460.     !VAR yyOldToNewCount    : INTEGER;!
  461.     !!
  462.     !PROCEDURE yyStoreOldToNew (yyOld, yyNew: ! WI (itTree); !);!
  463.     ! BEGIN!
  464.     !  INC (yyOldToNewCount);!
  465.     !  IF (yyOldToNewCount = yyOldToNewStoreSize) THEN!
  466.     !   DynArray.ExtendArray (yyOldToNewStorePtr, yyOldToNewStoreSize, SYSTEM.TSIZE (yytOldToNew));!
  467.     !  END;!
  468.     !  yyOldToNewStorePtr^[yyOldToNewCount].yyOld := yyOld;!
  469.     !  yyOldToNewStorePtr^[yyOldToNewCount].yyNew := yyNew;!
  470.     ! END yyStoreOldToNew;!
  471.     !!
  472.     !PROCEDURE yyMapOldToNew (yyOld: ! WI (itTree); !): ! WI (itTree); !;!
  473.     ! VAR yyi: INTEGER;!
  474.     ! BEGIN!
  475.     !  FOR yyi := 1 TO yyOldToNewCount DO!
  476.     !   IF yyOldToNewStorePtr^[yyi].yyOld = yyOld THEN!
  477.     !    RETURN yyOldToNewStorePtr^[yyi].yyNew;!
  478.     !   END;!
  479.     !  END;!
  480.     ! END yyMapOldToNew;!
  481.     !!
  482.     !PROCEDURE yyCopy! WI (iModule); ! (yyt: ! WI (itTree); !; yyNew: yyPtrtTree);!
  483.     ! BEGIN!
  484.     !  LOOP!
  485.     !   IF yyt = ! WI (iNoTree); ! THEN yyNew^ := ! WI (iNoTree); !; RETURN; END;!
  486.     !   IF yyt^.yyHead.yyMark = 0 THEN yyNew^ := yyMapOldToNew (yyt); RETURN; END;!
  487.     !   yyNew^ := Make! WI (iMain); ! (yyt^.Kind);!
  488.     !   IF yyt^.yyHead.yyMark > 1 THEN yyStoreOldToNew (yyt, yyNew^); END;!
  489.     !   yyt^.yyHead.yyMark := 0;!
  490.     !!
  491.     !   CASE yyt^.Kind OF!
  492.     ForallClasses (Classes, Copy);
  493.     !   ELSE!
  494.     !   END;!
  495.     !  END;!
  496.     ! END yyCopy! WI (iModule); !;!
  497.     !!
  498.     !PROCEDURE Copy! WI (iModule); ! (yyt: ! WI (itTree); !): ! WI (itTree); !;!
  499.     ! VAR yyNew    : ! WI (itTree); !;!
  500.     ! BEGIN!
  501.     !  yyMark (yyt);!
  502.     !  yyOldToNewCount := 0;!
  503.     !  yyCopy! WI (iModule); ! (yyt, SYSTEM.ADR (yyNew));!
  504.     !  RETURN yyNew;!
  505.     ! END Copy! WI (iModule); !;!
  506.     !!
  507.       END;
  508.       IF IsElement (ORD ('k'), Options) THEN
  509.     !PROCEDURE Check! WI (iModule); ! (yyt: ! WI (itTree); !): BOOLEAN;!
  510.     ! BEGIN!
  511.     !  yyMark (yyt);!
  512.     !  RETURN yyCheck! WI (iModule); ! (yyt);!
  513.     ! END Check! WI (iModule); !;!
  514.     !!
  515.     !PROCEDURE yyCheckChild (yyParent, yyChild: ! WI (itTree); !; yyType: SHORTCARD; yySelector: ARRAY OF CHAR): BOOLEAN;!
  516.     ! CONST yyf    = IO.StdError;!
  517.     ! VAR yySuccess    : BOOLEAN;!
  518.     ! BEGIN!
  519.     !  yySuccess := IsType (yyChild, yyType);!
  520.     !  IF NOT yySuccess THEN!
  521.     !   IO.WriteS (yyf, 'CheckTree: parent = ');!
  522.     !   Write! WI (iModule); !Node (yyf, yyParent);!
  523.     !   IO.WriteNl (yyf);!
  524.     !   IO.WriteS (yyf, 'selector: ');!
  525.     !   IO.WriteS (yyf, yySelector);!
  526.     !   IO.WriteS (yyf, ', child = ');!
  527.     !   Write! WI (iModule); !Node (yyf, yyChild);!
  528.     !   IO.WriteNl (yyf);!
  529.     !  END;!
  530.     !  RETURN yyCheck! WI (iModule); ! (yyChild) AND yySuccess;!
  531.     ! END yyCheckChild;!
  532.     !!
  533.     !PROCEDURE yyCheck! WI (iModule); ! (yyt: ! WI (itTree); !): BOOLEAN;!
  534.     ! VAR yyResult    : BOOLEAN;!
  535.     ! BEGIN!
  536.     !  IF yyt = ! WI (iNoTree); ! THEN RETURN FALSE;!
  537.     !  ELSIF yyt^.yyHead.yyMark = 0 THEN RETURN TRUE;!
  538.     !  END;!
  539.     !  yyt^.yyHead.yyMark := 0;!
  540.     !!
  541.     !  yyResult := TRUE;!
  542.     !  CASE yyt^.Kind OF!
  543.     ForallClasses (Classes, CheckAttributes);
  544.     !  ELSE!
  545.     !  END;!
  546.     !  RETURN yyResult;!
  547.     ! END yyCheck! WI (iModule); !;!
  548.     !!
  549.       END;
  550.       IF IsElement (ORD ('q'), Options) THEN
  551.     !CONST yyyWrite = 1; yyyRead = 2; yyyQuit = 3;!
  552.     !!
  553.     !VAR yyString    : ARRAY [0..31] OF CHAR;!
  554.     !VAR yyLength    : INTEGER;!
  555.     !VAR yyCh    : CHAR;!
  556.     !VAR yyState    : INTEGER;!
  557.     !!
  558.     !PROCEDURE yyyIsEqual (yya: ARRAY OF CHAR): BOOLEAN;!
  559.     ! VAR yyi    : INTEGER;!
  560.     ! BEGIN!
  561.     !  IF (yyLength >= 0) AND (yyString [yyLength] = ' ') THEN!
  562.     !   IF yyLength - 1 # INTEGER (HIGH (yya)) THEN RETURN FALSE; END;!
  563.     !   FOR yyi := 0 TO yyLength - 1 DO!
  564.     !    IF yyString [yyi] # yya [yyi] THEN RETURN FALSE; END;!
  565.     !   END;!
  566.     !  ELSE!
  567.     !   IF yyLength > INTEGER (HIGH (yya)) THEN RETURN FALSE; END;!
  568.     !   FOR yyi := 0 TO yyLength DO!
  569.     !    IF yyString [yyi] # yya [yyi] THEN RETURN FALSE; END;!
  570.     !   END;!
  571.     !  END;!
  572.     !  RETURN TRUE;!
  573.     ! END yyyIsEqual;!
  574.     !!
  575.     !PROCEDURE Query! WI (iModule); ! (yyt: ! WI (itTree); !);!
  576.     ! BEGIN!
  577.     !  yyState := yyyWrite;!
  578.     !  LOOP!
  579.     !   CASE yyState OF!
  580.     !   | yyyQuit    : RETURN;!
  581.     !   | yyyWrite    : Write! WI (iModule); !Node (IO.StdOutput, yyt); yyState := yyyRead;!
  582.     !   | yyyRead    : IO.WriteS (IO.StdOutput, '? '); yyLength := -1; yyCh := IO.ReadC (IO.StdInput);!
  583.     !    WHILE yyCh # 12C DO INC (yyLength); yyString [yyLength] := yyCh; yyCh := IO.ReadC (IO.StdInput); END;!
  584.     !    IF    yyyIsEqual ('parent') THEN yyState := yyyWrite; RETURN;!
  585.     !    ELSIF yyyIsEqual ('quit'  ) THEN yyState := yyyQuit ; RETURN;!
  586.     !    ELSIF yyt # ! WI (iNoTree); ! THEN!
  587.     !     CASE yyt^.Kind OF!
  588.     ForallClasses (Classes, QueryAttributes);
  589.     !     ELSE!
  590.     !     END;!
  591.     !    END;!
  592.     !   END;!
  593.     !  END;!
  594.     ! END Query! WI (iModule); !;!
  595.     !!
  596.       END;
  597.       IF IsElement (ORD ('='), Options) THEN
  598.     !PROCEDURE yyIsEqual (yya, yyb: ARRAY OF SYSTEM.BYTE): BOOLEAN;!
  599.     ! VAR yyi    : INTEGER;!
  600.     ! BEGIN!
  601.     !  FOR yyi := 0 TO INTEGER (HIGH (yya)) DO!
  602.     !   IF yya [yyi] # yyb [yyi] THEN RETURN FALSE; END;!
  603.     !  END;!
  604.     !  RETURN TRUE;!
  605.     ! END yyIsEqual;!
  606.     !!
  607.     !PROCEDURE IsEqual! WI (iModule); ! (yyt1, yyt2: ! WI (itTree); !): BOOLEAN;!
  608.     ! BEGIN!
  609.     !  IF yyt1 = yyt2 THEN RETURN TRUE; END;!
  610.     !  IF (yyt1 = ! WI (iNoTree); !) OR (yyt2 = ! WI (iNoTree); !) OR (yyt1^.Kind # yyt2^.Kind) THEN RETURN FALSE; END;!
  611.     !  CASE yyt1^.Kind OF!
  612.     ForallClasses (Classes, IsEqualAttributes);
  613.     !  ELSE RETURN TRUE;!
  614.     !  END;!
  615.     ! END IsEqual! WI (iModule); !;!
  616.     !!
  617.       END;
  618.       IF IsElement (ORD ('L'), Options) THEN
  619.     MaxBit := 0;
  620.     ForallClasses (Classes, CompMaxBit);
  621.     !PROCEDURE Init! WI (iModule); ! (yyt: ! WI (itTree); !);!
  622.     ! BEGIN!
  623.     !  LOOP!
  624.     FOR i := 0 TO (MaxBit - 1) DIV BSS DO
  625.        !   yyt^.yyHead.yyIsComp! WN (i); ! := {};!
  626.       IF IsElement (ORD ('5'), Options) THEN
  627.        !   yyt^.yyHead.yyIsDone! WN (i); ! := {};!
  628.       END;
  629.     END;
  630.     !   CASE yyt^.Kind OF!
  631.     ForallClasses (Classes, InitAttributes);
  632.     !   ELSE RETURN;!
  633.     !   END;!
  634.     !  END;!
  635.     ! END Init! WI (iModule); !;!
  636.     !!
  637.       END;
  638.     !PROCEDURE Begin! WI (iModule); !;!
  639.     ! BEGIN!
  640.     WriteLine (TreeCodes^.Codes.BeginLine);
  641.     WriteText (f, TreeCodes^.Codes.Begin);
  642.     Node := Modules;
  643.     WHILE Node^.Kind = Tree.Module DO
  644.        WriteLine (Node^.Module.TreeCodes^.Codes.BeginLine);
  645.        WriteText (f, Node^.Module.TreeCodes^.Codes.Begin);
  646.        Node := Node^.Module.Next;
  647.     END;
  648.     ! END Begin! WI (iModule); !;!
  649.     !!
  650.     !PROCEDURE Close! WI (iModule); !;!
  651.     ! BEGIN!
  652.     WriteLine (TreeCodes^.Codes.CloseLine);
  653.     WriteText (f, TreeCodes^.Codes.Close);
  654.     Node := Modules;
  655.     WHILE Node^.Kind = Tree.Module DO
  656.        WriteLine (Node^.Module.TreeCodes^.Codes.CloseLine);
  657.        WriteText (f, Node^.Module.TreeCodes^.Codes.Close);
  658.        Node := Node^.Module.Next;
  659.     END;
  660.     ! END Close! WI (iModule); !;!
  661.     !!
  662.       IF NOT IsElement (ORD ('<'), Options) THEN
  663.     !PROCEDURE xxExit;!
  664.     ! BEGIN!
  665.     !  IO.CloseIO; System.Exit (1);!
  666.     ! END xxExit;!
  667.     !!
  668.       END;
  669.     !BEGIN!
  670.       IF IsElement (ORD ('r'), Options) THEN
  671.     ! yyIsInitialized := FALSE;!
  672.       END;
  673.       IF NOT IsElement (ORD ('<'), Options) THEN
  674.     ! yyBlockList    := NIL;!
  675.     ! yyPoolFreePtr    := NIL;!
  676.     ! yyPoolMaxPtr    := NIL;!
  677.     ! HeapUsed    := 0;!
  678.     ! yyExit    := xxExit;!
  679.     ForallClasses (Classes, InitNodeSize);
  680.     ! yyMaxSize    := 0;!
  681.     ! FOR yyi := 1 TO ! WN (ClassCount); ! DO!
  682.     !  yyNodeSize [yyi] := LONGINT (BITSET (yyNodeSize [yyi] + CARDINAL (General.MaxAlign) - 1) * General.AlignMasks [General.MaxAlign]);!
  683.     !  yyMaxSize := General.Max (yyNodeSize [yyi], yyMaxSize);!
  684.     ! END;!
  685.     ForallClasses (Classes, InitTypeRange);
  686.       END;
  687.       IF IsElement (ORD (';'), Options) THEN
  688.     ! yyRecursionLevel := 0;!
  689.           ! yyTreeStoreSize := yyInitTreeStoreSize;!
  690.           ! DynArray.MakeArray (yyTreeStorePtr, yyTreeStoreSize, SYSTEM.TSIZE (! WI (itTree); !));!
  691.       END;
  692.       IF IsElement (ORD ('y'), Options) THEN
  693.         ! yyOldToNewStoreSize := yyInitOldToNewStoreSize;!
  694.           ! DynArray.MakeArray (yyOldToNewStorePtr, yyOldToNewStoreSize, SYSTEM.TSIZE (yytOldToNew));!
  695.       END;
  696.     ! Begin! WI (iModule); !;!
  697.     !END ! WI (iModule); !.!
  698. }; .
  699.  
  700.  
  701. PROCEDURE ProcedureBodyn (t: Tree)
  702.  
  703. Class (..) :- {
  704.     IF (NoCodeClass * Properties) = {} THEN
  705.        !PROCEDURE n! WI (Name); ! (): ! WI (itTree); !;!
  706.        ! VAR yyByteCount    : LONGINT;!
  707.        ! VAR yyt    : ! WI (itTree); !;!
  708.        ! BEGIN!
  709.        !  yyALLOC (yyt, yyNodeSize [! WI (Name); !])!
  710.        !  yyt^.yyHead.yyMark := 0;!
  711.        !  yyt^.Kind := ! WI (Name); !;!
  712.        iClassName := Name;
  713.        ForallAttributes (t, ProcedureBodyn);
  714.        !  RETURN yyt;!
  715.        ! END n! WI (Name); !;!
  716.        !!
  717.     END;
  718. }; .
  719. Child (..) :- {
  720.     !  begin! WI (itTree); !(yyt^.! WI (iClassName); !.! WI (Name); !)!
  721. }; .
  722. Attribute (..) :- {
  723.     IF (NoCodeAttr * Properties) = {} THEN 
  724.        !  begin! WI (Type); !(yyt^.! WI (iClassName); !.! WI (Name); !)!
  725.     END;
  726. }; .
  727.  
  728.  
  729. PROCEDURE ProcedureBodym (t: Tree)
  730.  
  731. Class (..) :- {
  732.     IF (NoCodeClass * Properties) = {} THEN
  733.        ProcedureHeadingm (t);
  734.        ! VAR yyByteCount    : LONGINT;!
  735.        ! VAR yyt    : ! WI (itTree); !;!
  736.        ! BEGIN!
  737.        !  yyALLOC (yyt, yyNodeSize [! WI (Name); !])!
  738.        !  yyt^.yyHead.yyMark := 0;!
  739.        !  yyt^.Kind := ! WI (Name); !;!
  740.        IF ({HasChildren, HasAttributes} * Properties) # {} THEN
  741.           !  WITH yyt^.! WI (Name); ! DO!
  742.           ForallAttributes (t, ProcedureBodym);
  743.           !  END;!
  744.        END;
  745.        !  RETURN yyt;!
  746.        ! END m! WI (Name); !;!
  747.        !!
  748.     END;
  749. }; .
  750. Child (..) :- {
  751.     IF Input IN Properties THEN
  752.        !   ! WI (Name); ! := p! WI (Name); !;!
  753.     ELSE
  754.        !   begin! WI (itTree); !(! WI (Name); !)!
  755.     END;
  756. }; .
  757. Attribute (..) :- {
  758.     IF (NoCodeAttr * Properties) = {} THEN 
  759.        IF Input IN Properties THEN
  760.           !   ! WI (Name); ! := p! WI (Name); !;!
  761.        ELSE
  762.           !   begin! WI (Type); !(! WI (Name); !)!
  763.        END;
  764.     END;
  765. }; .
  766.  
  767.  
  768. PROCEDURE ReleaseAttributes1 (t: Tree)
  769.  
  770. Class (..) :- {
  771.     IF ((NoCodeClass * Properties) = {}) AND (HasChildren IN Properties) THEN
  772.        !| ! WI (Name); !:!
  773.        iClassName := Name;
  774.        ForallAttributes (t, ReleaseAttributes1);
  775.     END;
  776. }; .
  777. Child (..) :- {
  778.     !close! WI (itTree); ! (yyt^.! WI (iClassName); !.! WI (Name); !)!
  779. }; .
  780.  
  781.  
  782. PROCEDURE ReleaseAttributes2 (t: Tree)
  783.  
  784. Class (..) :- {
  785.     IF ((NoCodeClass * Properties) = {}) AND (HasAttributes IN Properties) THEN
  786.        !| ! WI (Name); !:!
  787.        iClassName := Name;
  788.        ForallAttributes (t, ReleaseAttributes2);
  789.     END;
  790. }; .
  791. Attribute (..) :- {
  792.     IF (NoCodeAttr * Properties) = {} THEN 
  793.        !close! WI (Type); ! (yyt^.! WI (iClassName); !.! WI (Name); !)!
  794.     END;
  795. }; .
  796.  
  797.  
  798. PROCEDURE TraverseTD (t: Tree)
  799.  
  800. Class (..) :- {
  801.     IF ((NoCodeClass * Properties) = {}) AND (HasChildren IN Properties) THEN
  802.        !| ! WI (Name); !:!
  803.        GetIterator (t);
  804.        iClassName := Name;
  805.        ForallAttributes (t, TraverseTD);
  806.        IF Iterator = NoTree THEN
  807.           !RETURN;!
  808.        ELSE
  809.           !yyt := yyt^.! WI (iClassName); !.! WI (Iterator^.Child.Name); !;!
  810.        END;
  811.     END;
  812. }; .
  813. Child (..) :- {
  814.     IF t # Iterator THEN
  815.        !yyTraverse! WI (iModule); !TD (yyt^.! WI (iClassName); !.! WI (Name); !);!
  816.     END;
  817. }; .
  818.  
  819.  
  820. PROCEDURE TraverseBU (t: Tree)
  821.  
  822. Class (..) :- {
  823.     IF ((NoCodeClass * Properties) = {}) AND (HasChildren IN Properties) THEN
  824.        !| ! WI (Name); !:!
  825.        GetIterator (t);
  826.        iClassName := Name;
  827.        ForallAttributes (t, TraverseBU);
  828.        IF Iterator = NoTree THEN
  829.           !RETURN;!
  830.        ELSE
  831.           !yyTraverse! WI (iModule); !BU (yyt^.! WI (iClassName); !.! WI (Iterator^.Child.Name); !);!
  832.        END;
  833.     END;
  834. }; .
  835. Child (..) :- {
  836.     IF t # Iterator THEN
  837.        !yyTraverse! WI (iModule); !BU (yyt^.! WI (iClassName); !.! WI (Name); !);!
  838.     END;
  839. }; .
  840.  
  841.  
  842. PROCEDURE Reverse1 (t: Tree)
  843.  
  844. Class (..) :- {
  845.     IF (NoCodeClass * Properties) = {} THEN
  846.        iClassName := Name;
  847.        ForallAttributes (t, Reverse1);
  848.     END;
  849. }; .
  850. Child (..) :- {
  851.     IF Reverse IN Properties THEN
  852.        !| ! WI (iClassName); !: yyNext := yyOld^.! WI (iClassName); !.! WI (Name); !;! 
  853.        ! yyOld^.! WI (iClassName); !.! WI (Name); ! := yyNew;!
  854.     END;
  855. }; .
  856.  
  857.  
  858. PROCEDURE Reverse2 (t: Tree)
  859.  
  860. Class (..) :- {
  861.     IF (NoCodeClass * Properties) = {} THEN
  862.        iClassName := Name;
  863.        ForallAttributes (t, Reverse2);
  864.     END;
  865. }; .
  866. Child (..) :- {
  867.     IF Reverse IN Properties THEN
  868.        !| ! WI (iClassName); !: yyTail^.! WI (iClassName); !.! WI (Name); ! := yyOld;!
  869.     END;
  870. }; .
  871.  
  872.  
  873. PROCEDURE Copy (t: Tree)
  874.  
  875. Class (..) :- {
  876.     IF (NoCodeClass * Properties) = {} THEN
  877.        !| ! WI (Name); !: yyNew^^.! WI (Name); ! := yyt^.! WI (Name); !;!
  878.        GetIterator (t);
  879.        iClassName := Name;
  880.        ForallAttributes (t, Copy);
  881.        IF Iterator = NoTree THEN
  882.           !RETURN;!
  883.        ELSE
  884.           !yyt := yyt^.! WI (Name); !.! WI (Iterator^.Child.Name); !;!
  885.           !yyNew := SYSTEM.ADR (yyNew^^.! WI (Name); !.! WI (Iterator^.Child.Name); !);!
  886.        END;
  887.     END;
  888. }; .
  889. Child (..) :- {
  890.     IF t # Iterator THEN
  891.        !copy! WI (itTree); ! (yyNew^^.! WI (iClassName); !.! WI (Name); !, ! 
  892.           !yyt^.! WI (iClassName); !.! WI (Name); !)!
  893.     END;
  894. }; .
  895. Attribute (..) :- {
  896.     IF (NoCodeAttr * Properties) = {} THEN 
  897.        !copy! WI (Type); ! (yyNew^^.! WI (iClassName); !.! WI (Name); !, ! 
  898.           !yyt^.! WI (iClassName); !.! WI (Name); !)!
  899.     END;
  900. }; .
  901.  
  902.  
  903. PROCEDURE CheckAttributes (t: Tree)
  904.  
  905. Class (..) :- {
  906.     IF ((NoCodeClass * Properties) = {}) AND (HasChildren IN Properties) THEN
  907.        !| ! WI (Name); !:!
  908.        iClassName := Name;
  909.        ForallAttributes (t, CheckAttributes);
  910.     END;
  911. }; .
  912. Child (..) :- {
  913.     !yyResult := yyCheckChild (yyt, yyt^.! WI (iClassName); !.! WI (Name); !, ! 
  914.     WI (Type); !, '! WI (Name); !') AND yyResult;!
  915. }; .
  916.  
  917.  
  918. PROCEDURE InitTypeRange (t: Tree)
  919.  
  920. Class (..) :- {
  921.     IF (NoCodeClass * Properties) = {} THEN
  922.        iRange := Name;
  923.        ForallClasses (Extensions, InitTypeRange2);
  924.        ! yyTypeRange [! WI (Name); !] := ! WI (iRange); !;!
  925.     END;
  926. }; .
  927.  
  928.  
  929. PROCEDURE InitTypeRange2 (t: Tree)
  930.  
  931. Class (..) :- {
  932.     iRange := Name;
  933. }; .
  934.  
  935.  
  936. PROCEDURE QueryAttributes (t: Tree)
  937.  
  938. Class (..) :- {
  939.     IF ((NoCodeClass * Properties) = {}) AND (HasChildren IN Properties) THEN
  940.        !| ! WI (Name); !: IF FALSE THEN!
  941.        iClassName := Name;
  942.        ForallAttributes (t, QueryAttributes);
  943.        !END;!
  944.     END;
  945. }; .
  946. Child (..) :- {
  947.     !ELSIF yyyIsEqual ('! WI (Name); !') THEN Query! WI (iModule);
  948.     ! (yyt^.! WI (iClassName); !.! WI (Name); !);!
  949. }; .
  950.  
  951.  
  952. PROCEDURE IsEqualAttributes (t: Tree)
  953.  
  954. Class (..) :- {
  955.     IF ((NoCodeClass * Properties) = {}) AND
  956.        (({HasChildren, HasAttributes} * Properties) # {}) THEN
  957.        !| ! WI (Name); !: RETURN TRUE!
  958.        iClassName := Name;
  959.        ForallAttributes (t, IsEqualAttributes);
  960.     END;
  961. }; .
  962. Child (..) :- {
  963.     !AND equal! WI (itTree); ! (yyt1^.! WI (iClassName); !.! WI (Name);
  964.     !, yyt2^.! WI (iClassName); !.! WI (Name); !)!
  965. }; .
  966. Attribute (..) :- {
  967.     IF (NoCodeAttr * Properties) = {} THEN 
  968.        !AND (equal! WI (Type); ! (yyt1^.! WI (iClassName); !.! WI (Name);
  969.        !, yyt2^.! WI (iClassName); !.! WI (Name); !))!
  970.     END;
  971. }; .
  972.  
  973.  
  974. PROCEDURE InitAttributes (t: Tree)
  975.  
  976. Class (..) :-
  977.     ((NoCodeClass * Properties) = {{}}) AND (HasChildren IN Properties);
  978.     !| ! WI (Name); !:!
  979.     GetIterator (t);
  980.     iClassName := Name;
  981.     gBitCount := BitCount;
  982.     ForallAttributes (t, InitAttributes);
  983. {    IF (Iterator = NoTree) OR NOT (Input IN Iterator^.Child.Properties) THEN
  984.        !RETURN;!
  985.     ELSE
  986.        !yyt := yyt^.! WI (iClassName); !.! WI (Iterator^.Child.Name); !;!
  987.     END;
  988. };    .
  989. Child (..) :-
  990.     Input IN Properties;
  991.     !WITH yyt^.! WI (iClassName); !.! WI (Name); !^.yyHead DO yyOffset := ! 
  992.     WN (gBitCount + BitOffset); !; yyParent := yyt; END;!
  993.     t # Iterator;
  994.     !Init! WI (iModule); ! (yyt^.! WI (iClassName); !.! WI (Name); !);!
  995.     .
  996.  
  997. PROCEDURE InitNodeSize (t: Tree)
  998.  
  999. Class (..) :-
  1000.     (NoCodeClass * Properties) = {{}};
  1001.     ! yyNodeSize [! WI (Name); !] := SYSTEM.TSIZE (y! WI (Name); !);!
  1002.     .
  1003.  
  1004. PROCEDURE ImportList (t: Tree)
  1005.  
  1006. Ag (..) :- {
  1007.     !FROM ! WI (iMain); ! IMPORT!
  1008.       IF NOT IsElement (ORD ('<'), Options) THEN
  1009.     WI (iNoTree); !, ! WI (itTree); !, ! WI (iMain); !Root, Make! WI (iMain); !,!
  1010.       END;
  1011.     ForallClasses (Classes, ImportList);
  1012.       IF IsElement (ORD ('f'), Options) THEN
  1013.     !Release! WI (iModule); !,!
  1014.       END;
  1015.       IF IsElement (ORD ('F'), Options) AND NOT IsElement (ORD ('<'), Options) THEN
  1016.     !Release! WI (iModule); !Module,!
  1017.       END;
  1018.       IF IsElement (ORD ('o'), Options) THEN
  1019.     !Write! WI (iModule); !Node,!
  1020.       END;
  1021.       IF IsElement (ORD ('w'), Options) THEN
  1022.     !Write! WI (iModule); !,!
  1023.       END;
  1024.       IF IsElement (ORD ('r'), Options) THEN
  1025.     !Read! WI (iModule); !,!
  1026.       END;
  1027.       IF IsElement (ORD ('p'), Options) THEN
  1028.     !Put! WI (iModule); !,!
  1029.       END;
  1030.       IF IsElement (ORD ('g'), Options) THEN
  1031.     !Get! WI (iModule); !,!
  1032.       END;
  1033.       IF IsElement (ORD ('t'), Options) THEN
  1034.     !Traverse! WI (iModule); !TD,!
  1035.       END;
  1036.       IF IsElement (ORD ('b'), Options) THEN
  1037.     !Traverse! WI (iModule); !BU,!
  1038.       END;
  1039.       IF IsElement (ORD ('R'), Options) THEN
  1040.     !Reverse! WI (iModule); !,!
  1041.       END;
  1042.       IF IsElement (ORD ('y'), Options) THEN
  1043.     !Copy! WI (iModule); !,!
  1044.       END;
  1045.       IF IsElement (ORD ('k'), Options) THEN
  1046.     !Check! WI (iModule); !,!
  1047.       END;
  1048.       IF IsElement (ORD ('q'), Options) THEN
  1049.     !Query! WI (iModule); !,!
  1050.       END;
  1051.       IF IsElement (ORD ('='), Options) THEN
  1052.     !IsEqual! WI (iModule); !,!
  1053.       END;
  1054.       IF IsElement (ORD ('L'), Options) THEN
  1055.     !Init! WI (iModule); !,!
  1056.       END;
  1057.     !Begin! WI (iModule); !,!
  1058.     !Close! WI (iModule); !;!
  1059. }; .
  1060. Class (..) :- {
  1061.     IF (NoCodeClass * Properties) = {} THEN
  1062.        WI (Name); !, ! 
  1063.       IF IsElement (ORD ('n'), Options) THEN
  1064.        !n! WI (Name); !, ! 
  1065.       END;
  1066.       IF IsElement (ORD ('m'), Options) THEN
  1067.        !m! WI (Name); !,!
  1068.       END;
  1069.     END;
  1070. }; .
  1071.  
  1072.  
  1073. PROCEDURE ImportConst (t: Tree)
  1074.  
  1075. Class (..) :- {
  1076.     IF (NoCodeClass * Properties) = {} THEN
  1077.        WI (Name); !, !
  1078.     END;
  1079. }; .
  1080.  
  1081. PROCEDURE CompMaxBit (t: Tree)
  1082.  
  1083. Class (..) :-
  1084.     i := 1;
  1085.     ForallAttributes (t, CompMaxBit);
  1086.     MaxBit := Max (i, MaxBit);
  1087.     .
  1088. Child (..) ;
  1089. Attribute (..) :-
  1090.     ({{Input, Test, Dummy}} * Properties = {{}});
  1091.     INC (i);
  1092.     .
  1093.